<template>
	<view >
		<view style="color: #B31610;height: 30px;">
			达标剩余时长：{{movieViewTime}}
		</view>
		<view class="style1" :style="'height:'+webViewHeight+'px;'">
			<web-view  :src="playUrlVovi"></web-view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			var con = '/static/banner/vr.png'
			return{
				playUrlVovi: "", //全景的url
				      commitVoviloading: false, //全景dialog加载
				      voviViewTime: "", //全景显示时间
				      voviViewInterval: "",
				      voviViewUseTime: "", //全景观看经过的时间
					  currentTime:'',
					  okTime:'',
					  commitStatus:'',
				winHeight:getApp().globalData.winHeight,
				tabBarHeight:getApp().globalData.tabBarHeight,
				webViewHeight:0,
				// conte:[],
				url:'http://www.sizhengziyuanku.com/',
				id:'',
			}
		},
		created() {
			this.webViewHeight = this.winHeight;
			console.log(this.webViewHeight);
			// console.log(this.tabBarHeight);
		},
		methods:{
			    //更新持续任务的时间
			    updateTaskedTime(Type, time, taskedId) {
			      let that = this;
			      if (that.commitStatus != 3)
			        that.pyReq(
			          that.$http.updateTaskedTime,
			          { Type: Type, time: time, taskedId: taskedId },
			          function (res) {}
			        );
			    },
			    //将时间格式化为 分钟:秒钟
			    formatTime(second) {
			      let min = Math.floor(second / 60);
			      let sec = second % 60;
			      if (sec < 10) return min + "：0" + sec;
			      else return min + "：" + sec;
			    },
		},
		onBackPress(){
			      if (this.voviViewInterval) clearInterval(this.voviViewInterval);
			      this.updateTaskedTime(4, this.voviViewUseTime, this.id);
		},
		onLoad(option) {
			let that = this;
			this.id = option.id
			this.playUrlVovi = option.playUrlVovi
			this.currentTime = option.time
			this.okTime = option.okTime
			this.commitStatus = option.commitStatus

			          let time = this.currentTime;
			          let okTime = this.okTime;
			          let count = 0;
			          that.voviViewUseTime = 180 - (okTime - time - count);
			          that.voviViewTime = that.formatTime(okTime - time - count);
					  uni.setNavigationBarTitle({
					  　　title:'达标剩余时长： '+that.voviViewTime
					  })
			          if (okTime - time - count <= 0) {
			            that.voviViewTime = "已完成";
						uni.setNavigationBarTitle({
						　　title:'达标剩余时长： '+that.voviViewTime
						})
			          }
			          if (that.commitStatus != 3)
			            that.voviViewInterval = setInterval(function () {
			              that.voviViewUseTime = 180 - (okTime - time - count);
			              that.voviViewTime = that.formatTime(okTime - time - count);
						  uni.setNavigationBarTitle({
						  　　title:'达标剩余时长： '+that.voviViewTime
						  })
			              if (okTime - time - count <= 0) {
			                clearInterval(that.voviViewInterval);
			                that.voviViewTime = "已完成";
							uni.setNavigationBarTitle({
							　　title:'达标剩余时长： '+that.voviViewTime
							})
			                that.updateTaskedTime(4, that.voviViewUseTime, that.id);
			              }
			              count++;
			            }, 1000);
					
		}
	}
</script>

<style>
.style1{
	width: 100%;
	/* height: 200upx; */
	/* background-color: #007AFF; */
}
.uni-app--showtabbar uni-page-wrapper::after {
    height: 0px;
    /* height: calc(50px + constant(safe-area-inset-bottom)); */
    /* height: calc(50px + env(safe-area-inset-bottom)); */
}
</style>
